<template>
  <div class="read">
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">博客首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="javascript:;">博客详情</a></el-breadcrumb-item>
    </el-breadcrumb>
    <h2 class="title">{{blogDetails.title}}</h2>
    <div class="time">
      <div class="left">{{parseFloat(blogDetails.date) | dateFormat}}</div>
      <div class="right">
        <span class="iconfont icon-zan">&nbsp;{{blogDetails.top}}</span>
        <span class="iconfont icon-cai">&nbsp;{{blogDetails.trample}}</span>
      </div>
    </div>
    <pre class="container">{{blogDetails.text}}</pre>
  </div>
</template>

<script>
  import {mapState} from 'vuex'

  export default {
    name: "Read",
    created() {
      this.getBlogDetails()
    },
    methods: {
      getBlogDetails() {
        this.$destroy(true)
        this.$store.dispatch('blogDetails', this.$store.state.blogId)
      }
    },
    computed:{
      ...mapState(['blogDetails'])
    }
  }
</script>

<style scoped lang="less">
  .read {
    width: 800px;
    margin: auto;
    height: 100%;

    .title {
      text-align: center;
      font-size: 30px;
      margin: 20px 0;
    }

    .container {
      line-height: 20px;
      white-space: pre-line;
      background: #1A181D;
      padding: 20px;
      box-shadow: 0 1px 1px #000,0 -1px 1px #1A181D;
      border-radius: 5px;
    }

    .time {
      width: 100%;
      background: #181818;
      overflow: hidden;
      padding: 10px;
      margin-top: 30px;
      margin-bottom: 10px;
      border-radius: 5px;

      .left {
        float: left;
      }

      .right {
        float: right;

        span {
          margin-right: 10px;
          vertical-align: middle;
        }
      }
    }
  }
</style>